HAL COMP constants migration

This section provides information about the HAL COMP constants migration.

HAL COMP input hysteresis

For certain series, the migration process is as follows:

HAL1

HAL2



#define COMP_HYSTERESIS_10MV
#define COMP_HYSTERESIS_20MV
#define COMP_HYSTERESIS_30MV
#define COMP_HYSTERESIS_40MV
#define COMP_HYSTERESIS_50MV
#define COMP_HYSTERESIS_60MV
#define COMP_HYSTERESIS_70MV
typedef enum
{
  HAL_COMP_INPUT_HYSTERESIS_10MV,
  HAL_COMP_INPUT_HYSTERESIS_20MV,
  HAL_COMP_INPUT_HYSTERESIS_30MV,
  HAL_COMP_INPUT_HYSTERESIS_40MV,
  HAL_COMP_INPUT_HYSTERESIS_50MV,
  HAL_COMP_INPUT_HYSTERESIS_60MV,
  HAL_COMP_INPUT_HYSTERESIS_70MV
} hal_comp_input_hysteresis_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.Hysteresis = COMP_HYSTERESIS_10MV;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;
HAL_COMP_Init(COMP1);
comp_config->input_hysteresis = HAL_COMP_INPUT_HYSTERESIS_10MV;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

For the other series, refer to the migration detailed below:

HAL1

HAL2



#define COMP_HYSTERESIS_NONE
#define COMP_HYSTERESIS_LOW
#define COMP_HYSTERESIS_MEDIUM
#define COMP_HYSTERESIS_HIGH
typedef enum
{
  HAL_COMP_INPUT_HYSTERESIS_NONE,
  HAL_COMP_INPUT_HYSTERESIS_LOW,
  HAL_COMP_INPUT_HYSTERESIS_MEDIUM,
  HAL_COMP_INPUT_HYSTERESIS_HIGH

} hal_comp_input_hysteresis_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.Hysteresis = COMP_HYSTERESIS_NONE;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->input_hysteresis = HAL_COMP_INPUT_HYSTERESIS_NONE;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP input hysteresis, which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency:The constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_INPUT_HYSTERESIS_.

Related concept:


HAL COMP output blanking

HAL1

HAL2



#define COMP_BLANKINGSRC_TIM1_OC5_COMP1
#define COMP_BLANKINGSRC_TIM2_OC3_COMP1
#define COMP_BLANKINGSRC_TIM3_OC3_COMP7
...
typedef enum
{
  HAL_COMP_OUTPUT_BLANK_TIM1_OC5,
  HAL_COMP_OUTPUT_BLANK_TIM2_OC3,
  HAL_COMP_OUTPUT_BLANK_TIM3_OC3,
  ...
} hal_comp_output_blank_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.BlankingSrce = COMP_BLANKINGSRC_TIM1_OC5_COMP1;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_output_blank_t output_blank ;

HAL_COMP_Init(COMP1);
output_blank = HAL_COMP_INPUT_HYSTERESIS_NONE;
HAL_COMP_SetOutputBlanking(COMP1, output_blank);

Key changes

  • Conversion to enumerated type: the HAL COMP output blanking , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_OUTPUT_BLANK_

Related concept:


HAL COMP input minus

HAL1

HAL2



#define COMP_INPUT_MINUS_VREFINT
#define COMP_INPUT_MINUS_1_4VREFINT
#define COMP_INPUT_MINUS_IO1
#define COMP_INPUT_MINUS_DAC1_CH1
...
typedef enum
{
  HAL_COMP_INPUT_MINUS_VREFINT,
  HAL_COMP_INPUT_MINUS_1_4VREFINT,
  HAL_COMP_INPUT_MINUS_IO1,
  HAL_COMP_INPUT_MINUS_DAC1_CH1
  ...
} hal_comp_input_minus_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.InputMinus = COMP_INPUT_MINUS_VREFINT;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->input_minus = HAL_COMP_INPUT_MINUS_VREFINT;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP input minus , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_INPUT_MINUS_.

Related concept:


HAL COMP output level

HAL1

HAL2



#define COMP_OUTPUT_LEVEL_LOW
#define COMP_OUTPUT_LEVEL_HIGH
typedef enum
{
  HAL_COMP_OUTPUT_LEVEL_LOW,
  HAL_COMP_OUTPUT_LEVEL_HIGH
} hal_comp_output_level_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
uint32_t comp_output_level = 0;
HAL_COMP_Init(hcomp);
/*return output level*/
comp_output_level = HAL_COMP_GetOutputLevel(hcomp);

Usage example

hal_comp_output_level_t comp_output_level;
hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);

/*initialize the structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);
/*return output level*/
comp_output_level = HAL_COMP_GetOutputLevel(COMP1);

Key changes

  • Conversion to enumerated type: the HAL COMP output level , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_OUTPUT_LEVEL_.

Related concept:


HAL COMP power mode

HAL1

HAL2



#define COMP_POWERMODE_HIGHSPEED
#define COMP_POWERMODE_MEDIUMSPEED
#define COMP_POWERMODE_ULTRALOWPOWER
typedef enum
{
  HAL_COMP_POWER_MODE_HIGH_SPEED,
  HAL_COMP_POWER_MODE_MEDIUM_SPEED,
  HAL_COMP_POWER_MODE_ULTRA_LOW_POWER
} hal_comp_power_mode_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.Mode = COMP_POWERMODE_HIGHSPEED;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->power_mode = HAL_COMP_POWER_MODE_HIGH_SPEED;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP power mode , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_POWER_MODE_.

Related concept:


HAL COMP input plus

HAL1

HAL2



#define COMP_INPUT_PLUS_IO1
#define COMP_INPUT_PLUS_IO2
#define COMP_INPUT_PLUS_IO3
#define COMP_INPUT_PLUS_DAC1_CH1
...
typedef enum
{
  HAL_COMP_INPUT_PLUS_IO1,
  HAL_COMP_INPUT_PLUS_IO2,
  HAL_COMP_INPUT_PLUS_IO3,
  HAL_COMP_INPUT_PLUS_DAC1_CH1
  ...
} hal_comp_input_plus_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.InputPlus = COMP_INPUT_PLUS_IO1;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->input_plus = HAL_COMP_INPUT_PLUS_IO1;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP input plus , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_INPUT_PLUS_.

Related concept:


HAL COMP output polarity

HAL1

HAL2



#define COMP_OUTPUTPOL_NONINVERTED
#define COMP_OUTPUTPOL_INVERTED
typedef enum
{
  HAL_COMP_OUTPUT_POLARITY_NONINVERTED,
  HAL_COMP_OUTPUT_POLARITY_INVERTED
} hal_comp_output_polarity_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->output_polarity = HAL_COMP_OUTPUT_POLARITY_NONINVERTED;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP output polarity , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_OUTPUT_POLARITY_.

Related concept:


HAL COMP output trigger

HAL1

HAL2



#define COMP_TRIGGERMODE_NONE
#define COMP_TRIGGERMODE_EVENT_RISING_FALLING
#define COMP_TRIGGERMODE_EVENT_FALLING
#define COMP_TRIGGERMODE_EVENT_RISING
...
typedef enum
{
  HAL_COMP_OUTPUT_TRIG_NONE,
  HAL_COMP_OUTPUT_TRIG_RISING_FALLING,
  HAL_COMP_OUTPUT_TRIG_FALLING,
  HAL_COMP_OUTPUT_TRIG_RISING
  ...

} hal_comp_output_trigger_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.TriggerMode = COMP_TRIGGERMODE_NONE;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->output_trigger = HAL_COMP_OUTPUT_TRIG_NONE;
/*initialize the other structure members of hal_comp_config_t */
...
HAL_COMP_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP output trigger to system , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_OUTPUT_TRIG_.

Related concept:


HAL COMP window output

HAL1

HAL2



#define COMP_WINDOWOUTPUT_EACH_COMP
#define COMP_WINDOWOUTPUT_BOTH
typedef enum
{
  HAL_COMP_WINDOW_OUTPUT_INDEPT,
  HAL_COMP_WINDOW_OUTPUT_XOR
} hal_comp_window_output_mode_t;

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.WindowOutput = COMP_WINDOWOUTPUT_EACH_COMP;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_window_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->window_output_mode = HAL_COMP_WINDOW_OUTPUT_INDEPT;
/*initialize the other structure members of hal_comp_window_config_t */
...
HAL_COMP_WINDOW_SetConfig(COMP1, comp_config);

HAL1

HAL2

#define COMP_WINDOWOUTPUT_COMP1
#define COMP_WINDOWOUTPUT_COMP2
#define COMP_WINDOWOUTPUT_COMP3
- LL_COMP_WINDOW_OUTPUT_XOR_ODD
- LL_COMP_WINDOW_OUTPUT_XOR_EVEN
- LL_COMP_WINDOW_OUTPUT_XOR_EVEN

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_window_config_t *comp_config;

HAL_COMP_Init(COMP1);
comp_config->window_output_mode = HAL_COMP_WINDOW_OUTPUT_XOR;
/*initialize the other structure members of hal_comp_window_config_t */
...
HAL_COMP_WINDOW_SetConfig(COMP1, comp_config);

Key changes

  • Conversion to enumerated type: the HAL COMP output trigger to system , which were previously defined using #define directive , have been converted to an enumerated type (enum).

  • Renaming for consistency: the constants have been renamed to follow a consistent naming convention, prefixed with HAL_COMP_OUTPUT_TRIG_.

Related concept:


HAL COMP fields constants

HAL1

HAL2

#define COMP_FLAG_C1I
#define COMP_FLAG_LOCK
#define COMP_IT_EN
#define COMP_STATE_BITFIELD_LOCK
...

Removed ; used only by the internal implementation (not impacting the user).


HAL COMP error constants

HAL1

HAL2

#define HAL_COMP_ERROR_INVALID_CALLBACK
#define HAL_COMP_ERROR_NONE
...

Removed , COMP has no errors to report.


HAL COMP lock flag

HAL1

HAL2



#define COMP_FLAG_LOCK

Removed , In HAL2 the PWR main regulator is managed by unitary functions in the ll layer.

uint32_t LL_COMP_IsLocked(const COMP_TypeDef *p_comp)

HAL COMP Window mode constants

HAL1

HAL2

#define COMP_WINDOWMODE_DISABLE
...

Removed ; use LL_COMP_WINDOW_DISABLE instead.

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.WindowMode  = COMP_WINDOWMODE_DISABLE;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_window_config_t *comp_config;
/*initialize the  structure members of comp_config */
...
HAL_COMP_Init(COMP1);
HAL_COMP_SetConfig(COMP1, comp_config);

HAL1

HAL2

#define   COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
...

New usage sequence with dedicated window mode configuration functions.

Note

When calling the window mode configuration function, if COMP1 instance is provided, the WindowMode parameter should be set to COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON.

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP1;
hcomp->Init.WindowMode  = COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_window_config_t *comp_config;
hal_comp_handle_t        *hal_handle;
/*initialize the  structure members of comp_config */
...

HAL_COMP_Init(COMP1);
HAL_COMP_Init(COMP2);
HAL_COMP_WINDOW_SetHandle(COMP1,COMP2);
HAL_COMP_WINDOW_SetConfig(COMP1, comp_config);

HAL1

HAL2

#define   COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON
...

New usage sequence with dedicated window mode configuration functions

Note

When calling the window mode configuration function, if COMP2 instance is provided, the WindowMode parameter should be set to COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON.

Usage example

COMP_HandleTypeDef *hcomp;
hcomp->Instance = COMP2;
hcomp->Init.WindowMode  = COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON;
/*initialize the other Init structure members */
...
HAL_COMP_Init(hcomp);

Usage example

hal_comp_window_config_t *comp_config;
/*initialize the  structure members of comp_config */
...

HAL_COMP_Init(COMP1);
HAL_COMP_Init(COMP2);
HAL_COMP_WINDOW_SetHandle(COMP2,COMP1);
HAL_COMP_WINDOW_SetConfig(COMP2, comp_config);